// Source : http://www.tsinsen.com/A1079
// Author : Modnar
// Date   : 2019-03-25

#include <iostream>

const int MAX_SIZE     = 120;
const int MAX_DATA_NUM = 5;

int seq[MAX_SIZE][MAX_DATA_NUM] = {
                {1,2,3,4,5}, {1,2,3,5,4}, {1,2,4,3,5}, {1,2,4,5,3},
                {1,2,5,3,4}, {1,2,5,4,3}, {1,3,2,4,5}, {1,3,2,5,4},
                {1,3,4,2,5}, {1,3,4,5,2}, {1,3,5,2,4}, {1,3,5,4,2},
                {1,4,2,3,5}, {1,4,2,5,3}, {1,4,3,2,5}, {1,4,3,5,2},
                {1,4,5,2,3}, {1,4,5,3,2}, {1,5,2,3,4}, {1,5,2,4,3},
                {1,5,3,2,4}, {1,5,3,4,2}, {1,5,4,2,3}, {1,5,4,3,2},
                {2,1,3,4,5}, {2,1,3,5,4}, {2,1,4,3,5}, {2,1,4,5,3},
                {2,1,5,3,4}, {2,1,5,4,3}, {2,3,1,4,5}, {2,3,1,5,4},
                {2,3,4,1,5}, {2,3,4,5,1}, {2,3,5,1,4}, {2,3,5,4,1},
                {2,4,1,3,5}, {2,4,1,5,3}, {2,4,3,1,5}, {2,4,3,5,1},
                {2,4,5,1,3}, {2,4,5,3,1}, {2,5,1,3,4}, {2,5,1,4,3},
                {2,5,3,1,4}, {2,5,3,4,1}, {2,5,4,1,3}, {2,5,4,3,1},
                {3,1,2,4,5}, {3,1,2,5,4}, {3,1,4,2,5}, {3,1,4,5,2},
                {3,1,5,2,4}, {3,1,5,4,2}, {3,2,1,4,5}, {3,2,1,5,4},
                {3,2,4,1,5}, {3,2,4,5,1}, {3,2,5,1,4}, {3,2,5,4,1},
                {3,4,1,2,5}, {3,4,1,5,2}, {3,4,2,1,5}, {3,4,2,5,1},
                {3,4,5,1,2}, {3,4,5,2,1}, {3,5,1,2,4}, {3,5,1,4,2},
                {3,5,2,1,4}, {3,5,2,4,1}, {3,5,4,1,2}, {3,5,4,2,1},
                {4,1,2,3,5}, {4,1,2,5,3}, {4,1,3,2,5}, {4,1,3,5,2},
                {4,1,5,2,3}, {4,1,5,3,2}, {4,2,1,3,5}, {4,2,1,5,3},
                {4,2,3,1,5}, {4,2,3,5,1}, {4,2,5,1,3}, {4,2,5,3,1},
                {4,3,1,2,5}, {4,3,1,5,2}, {4,3,2,1,5}, {4,3,2,5,1},
                {4,3,5,1,2}, {4,3,5,2,1}, {4,5,1,2,3}, {4,5,1,3,2},
                {4,5,2,1,3}, {4,5,2,3,1}, {4,5,3,1,2}, {4,5,3,2,1},
                {5,1,2,3,4}, {5,1,2,4,3}, {5,1,3,2,4}, {5,1,3,4,2},
                {5,1,4,2,3}, {5,1,4,3,2}, {5,2,1,3,4}, {5,2,1,4,3},
                {5,2,3,1,4}, {5,2,3,4,1}, {5,2,4,1,3}, {5,2,4,3,1},
                {5,3,1,2,4}, {5,3,1,4,2}, {5,3,2,1,4}, {5,3,2,4,1},
                {5,3,4,1,2}, {5,3,4,2,1}, {5,4,1,2,3}, {5,4,1,3,2},
                {5,4,2,1,3}, {5,4,2,3,1}, {5,4,3,1,2}, {5,4,3,2,1}};
    
int symbol[MAX_SIZE] = { 
                1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 
                -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 
                1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 
                1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 
                -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 
                -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 
                1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 
                -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 
                -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 
                1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 
                1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 
                -1, 1, 1, -1, -1, 1, 1, -1, -1, 1};

int matrix[MAX_DATA_NUM][MAX_DATA_NUM];
        
int main(int argc, char *argv[]) {
    int n;
    std::cin >> n;
    for (int i = 0; i < MAX_DATA_NUM; ++i)
        matrix[i][i] = 1;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            std::cin >> matrix[i][j];
    int ans = 0;
    for (int i = 0; i < MAX_SIZE; ++i) {
        ans += matrix[0][seq[i][0]-1] * matrix[1][seq[i][1]-1] * 
               matrix[2][seq[i][2]-1] * matrix[3][seq[i][3]-1] * 
               matrix[4][seq[i][4]-1] * symbol[i];
    }
    std::cout << ans << std::endl;
    return 0;   
}
